.class public Llecho/lib/hellocharts/gesture/ChartZoomer;
.super Ljava/lang/Object;


# static fields
.field public static final ZOOM_AMOUNT:F = 0.25f


# instance fields
.field private scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

.field private viewportFocus:Landroid/graphics/PointF;

.field private zoomFocalPoint:Landroid/graphics/PointF;

.field private zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

.field private zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;


# direct methods
.method public constructor <init>(Landroid/content/Context;Llecho/lib/hellocharts/gesture/ZoomType;)V
    .locals 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    new-instance v0, Landroid/graphics/PointF;

    invoke-direct {v0}, Landroid/graphics/PointF;-><init>()V

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    new-instance v0, Landroid/graphics/PointF;

    invoke-direct {v0}, Landroid/graphics/PointF;-><init>()V

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->viewportFocus:Landroid/graphics/PointF;

    new-instance v0, Llecho/lib/hellocharts/model/Viewport;

    invoke-direct {v0}, Llecho/lib/hellocharts/model/Viewport;-><init>()V

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    new-instance v0, Llecho/lib/hellocharts/gesture/ZoomerCompat;

    invoke-direct {v0, p1}, Llecho/lib/hellocharts/gesture/ZoomerCompat;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;

    iput-object p2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

    return-void
.end method

.method private setCurrentViewport(Llecho/lib/hellocharts/computator/ChartComputator;FFFF)V
    .locals 3

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v0

    sget-object v1, Llecho/lib/hellocharts/gesture/ZoomType;->HORIZONTAL_AND_VERTICAL:Llecho/lib/hellocharts/gesture/ZoomType;

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

    if-ne v1, v2, :cond_1

    invoke-virtual {p1, p2, p3, p4, p5}, Llecho/lib/hellocharts/computator/ChartComputator;->setCurrentViewport(FFFF)V

    :cond_0
    :goto_0
    return-void

    :cond_1
    sget-object v1, Llecho/lib/hellocharts/gesture/ZoomType;->HORIZONTAL:Llecho/lib/hellocharts/gesture/ZoomType;

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

    if-ne v1, v2, :cond_2

    iget v1, v0, Llecho/lib/hellocharts/model/Viewport;->top:F

    iget v0, v0, Llecho/lib/hellocharts/model/Viewport;->bottom:F

    invoke-virtual {p1, p2, v1, p4, v0}, Llecho/lib/hellocharts/computator/ChartComputator;->setCurrentViewport(FFFF)V

    goto :goto_0

    :cond_2
    sget-object v1, Llecho/lib/hellocharts/gesture/ZoomType;->VERTICAL:Llecho/lib/hellocharts/gesture/ZoomType;

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

    if-ne v1, v2, :cond_0

    iget v1, v0, Llecho/lib/hellocharts/model/Viewport;->left:F

    iget v0, v0, Llecho/lib/hellocharts/model/Viewport;->right:F

    invoke-virtual {p1, v1, p3, v0, p5}, Llecho/lib/hellocharts/computator/ChartComputator;->setCurrentViewport(FFFF)V

    goto :goto_0
.end method


# virtual methods
.method public computeZoom(Llecho/lib/hellocharts/computator/ChartComputator;)Z
    .locals 8

    const/high16 v7, 0x3f800000    # 1.0f

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;

    invoke-virtual {v0}, Llecho/lib/hellocharts/gesture/ZoomerCompat;->computeZoom()Z

    move-result v0

    if-eqz v0, :cond_0

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;

    invoke-virtual {v0}, Llecho/lib/hellocharts/gesture/ZoomerCompat;->getCurrZoom()F

    move-result v0

    sub-float v0, v7, v0

    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {v1}, Llecho/lib/hellocharts/model/Viewport;->width()F

    move-result v1

    mul-float/2addr v0, v1

    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;

    invoke-virtual {v1}, Llecho/lib/hellocharts/gesture/ZoomerCompat;->getCurrZoom()F

    move-result v1

    sub-float v1, v7, v1

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {v2}, Llecho/lib/hellocharts/model/Viewport;->height()F

    move-result v2

    mul-float/2addr v1, v2

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    iget v2, v2, Landroid/graphics/PointF;->x:F

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    iget v3, v3, Llecho/lib/hellocharts/model/Viewport;->left:F

    sub-float/2addr v2, v3

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {v3}, Llecho/lib/hellocharts/model/Viewport;->width()F

    move-result v3

    div-float v4, v2, v3

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    iget v2, v2, Landroid/graphics/PointF;->y:F

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    iget v3, v3, Llecho/lib/hellocharts/model/Viewport;->bottom:F

    sub-float/2addr v2, v3

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {v3}, Llecho/lib/hellocharts/model/Viewport;->height()F

    move-result v3

    div-float v5, v2, v3

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    iget v2, v2, Landroid/graphics/PointF;->x:F

    mul-float v3, v0, v4

    sub-float/2addr v2, v3

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    iget v3, v3, Landroid/graphics/PointF;->y:F

    sub-float v6, v7, v5

    mul-float/2addr v6, v1

    add-float/2addr v3, v6

    iget-object v6, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    iget v6, v6, Landroid/graphics/PointF;->x:F

    sub-float v4, v7, v4

    mul-float/2addr v0, v4

    add-float v4, v6, v0

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    iget v0, v0, Landroid/graphics/PointF;->y:F

    mul-float/2addr v1, v5

    sub-float v5, v0, v1

    move-object v0, p0

    move-object v1, p1

    invoke-direct/range {v0 .. v5}, Llecho/lib/hellocharts/gesture/ChartZoomer;->setCurrentViewport(Llecho/lib/hellocharts/computator/ChartComputator;FFFF)V

    const/4 v0, 0x1

    :goto_0
    return v0

    :cond_0
    const/4 v0, 0x0

    goto :goto_0
.end method

.method public getZoomType()Llecho/lib/hellocharts/gesture/ZoomType;
    .locals 1

    iget-object v0, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

    return-object v0
.end method

.method public scale(Llecho/lib/hellocharts/computator/ChartComputator;FFF)Z
    .locals 6

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v0

    invoke-virtual {v0}, Llecho/lib/hellocharts/model/Viewport;->width()F

    move-result v0

    mul-float/2addr v0, p4

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v1

    invoke-virtual {v1}, Llecho/lib/hellocharts/model/Viewport;->height()F

    move-result v1

    mul-float/2addr v1, p4

    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->viewportFocus:Landroid/graphics/PointF;

    invoke-virtual {p1, p2, p3, v2}, Llecho/lib/hellocharts/computator/ChartComputator;->rawPixelsToDataPoint(FFLandroid/graphics/PointF;)Z

    move-result v2

    if-nez v2, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    iget-object v2, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->viewportFocus:Landroid/graphics/PointF;

    iget v2, v2, Landroid/graphics/PointF;->x:F

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v3

    iget v3, v3, Landroid/graphics/Rect;->left:I

    int-to-float v3, v3

    sub-float v3, p2, v3

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v4

    invoke-virtual {v4}, Landroid/graphics/Rect;->width()I

    move-result v4

    int-to-float v4, v4

    div-float v4, v0, v4

    mul-float/2addr v3, v4

    sub-float/2addr v2, v3

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->viewportFocus:Landroid/graphics/PointF;

    iget v3, v3, Landroid/graphics/PointF;->y:F

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v4

    iget v4, v4, Landroid/graphics/Rect;->top:I

    int-to-float v4, v4

    sub-float v4, p3, v4

    invoke-virtual {p1}, Llecho/lib/hellocharts/computator/ChartComputator;->getContentRectMinusAllMargins()Landroid/graphics/Rect;

    move-result-object v5

    invoke-virtual {v5}, Landroid/graphics/Rect;->height()I

    move-result v5

    int-to-float v5, v5

    div-float v5, v1, v5

    mul-float/2addr v4, v5

    add-float/2addr v3, v4

    add-float v4, v2, v0

    sub-float v5, v3, v1

    move-object v0, p0

    move-object v1, p1

    invoke-direct/range {v0 .. v5}, Llecho/lib/hellocharts/gesture/ChartZoomer;->setCurrentViewport(Llecho/lib/hellocharts/computator/ChartComputator;FFFF)V

    const/4 v0, 0x1

    goto :goto_0
.end method

.method public setZoomType(Llecho/lib/hellocharts/gesture/ZoomType;)V
    .locals 0

    iput-object p1, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomType:Llecho/lib/hellocharts/gesture/ZoomType;

    return-void
.end method

.method public startZoom(Landroid/view/MotionEvent;Llecho/lib/hellocharts/computator/ChartComputator;)Z
    .locals 4

    const/4 v0, 0x1

    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;

    invoke-virtual {v1, v0}, Llecho/lib/hellocharts/gesture/ZoomerCompat;->forceFinished(Z)V

    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->scrollerStartViewport:Llecho/lib/hellocharts/model/Viewport;

    invoke-virtual {p2}, Llecho/lib/hellocharts/computator/ChartComputator;->getCurrentViewport()Llecho/lib/hellocharts/model/Viewport;

    move-result-object v2

    invoke-virtual {v1, v2}, Llecho/lib/hellocharts/model/Viewport;->set(Llecho/lib/hellocharts/model/Viewport;)V

    invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F

    move-result v1

    invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F

    move-result v2

    iget-object v3, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomFocalPoint:Landroid/graphics/PointF;

    invoke-virtual {p2, v1, v2, v3}, Llecho/lib/hellocharts/computator/ChartComputator;->rawPixelsToDataPoint(FFLandroid/graphics/PointF;)Z

    move-result v1

    if-nez v1, :cond_0

    const/4 v0, 0x0

    :goto_0
    return v0

    :cond_0
    iget-object v1, p0, Llecho/lib/hellocharts/gesture/ChartZoomer;->zoomer:Llecho/lib/hellocharts/gesture/ZoomerCompat;

    const/high16 v2, 0x3e800000    # 0.25f

    invoke-virtual {v1, v2}, Llecho/lib/hellocharts/gesture/ZoomerCompat;->startZoom(F)V

    goto :goto_0
.end method
